//--------------------------------------------------------------------------------
// This file is part of the Windows Workflow Foundation Sample Code
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation.  See these other
// materials for detailed information regarding Microsoft code samples.
// 
// THIS CODE AND INFORMATION ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//--------------------------------------------------------------------------------

using System;
using System.Globalization;
using System.Resources;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace Microsoft.Samples.Workflow.UI
{
    [AttributeUsage(AttributeTargets.All)]
    class SRDescriptionAttribute : DescriptionAttribute
    {
        public SRDescriptionAttribute(string description)
        {
            DescriptionValue = SR.GetString(description);
        }

        public SRDescriptionAttribute(string description, string resourceSet)
        {
            ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
            DescriptionValue = rm.GetString(description);
            System.Diagnostics.Debug.Assert(DescriptionValue != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", description));
        }
    }

    [AttributeUsage(AttributeTargets.All)]
    class SRCategoryAttribute : CategoryAttribute
    {
        private string resourceSet = String.Empty;

        public SRCategoryAttribute(string category)
            : base(category)
        {
        }

        public SRCategoryAttribute(string category, string resourceSet)
            : base(category)
        {
            this.resourceSet = resourceSet;
        }

        protected override string GetLocalizedString(string value)
        {
            if (this.resourceSet.Length > 0)
            {
                ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
                String localizedString = rm.GetString(value);
                System.Diagnostics.Debug.Assert(localizedString != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", value));
                return localizedString;
            }
            else
            {
                return SR.GetString(value);
            }
        }
    }

    [AttributeUsage(AttributeTargets.All)]
    class SRDisplayNameAttribute : DisplayNameAttribute
    {
        public SRDisplayNameAttribute(string name)
        {
            DisplayNameValue = SR.GetString(name);
        }

        public SRDisplayNameAttribute(string name, string resourceSet)
        {
            ResourceManager rm = new ResourceManager(resourceSet, Assembly.GetExecutingAssembly());
            DisplayNameValue = rm.GetString(name);
            System.Diagnostics.Debug.Assert(DisplayNameValue != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", name));
        }
    }

    /// <summary>
    ///    AutoGenerated resource class. Usage:
    ///
    ///        string s = SR.GetString(SR.MyIdenfitier);
    /// </summary>
    class SR
    {
        static SR loader = null;
        ResourceManager resources;

        internal SR()
        {
            resources = new System.Resources.ResourceManager("Microsoft.Samples.Workflow.UI.Properties.Resources", Assembly.GetExecutingAssembly());
        }

        static SR GetLoader()
        {
            if (loader == null)
                loader = new SR();
            return loader;
        }

        static CultureInfo Culture
        {
            get { return null/*use ResourceManager default, CultureInfo.CurrentUICulture*/; }
        }

        internal static string GetString(string name, params object[] args)
        {
            return GetString(SR.Culture, name, args);
        }
        internal static string GetString(CultureInfo culture, string name, params object[] args)
        {
            SR sys = GetLoader();
            if (sys == null)
                return null;
            string res = sys.resources.GetString(name, culture);
            System.Diagnostics.Debug.Assert(res != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", name));
            if (args != null && args.Length > 0)
            {
                return String.Format(CultureInfo.CurrentCulture, res, args);
            }
            else
            {
                return res;
            }
        }

        internal static string GetString(string name)
        {
            return GetString(SR.Culture, name);
        }

        internal static string GetString(CultureInfo culture, string name)
        {
            SR sys = GetLoader();
            if (sys == null)
                return null;
            string res = sys.resources.GetString(name, culture);
            System.Diagnostics.Debug.Assert(res != null, string.Format(CultureInfo.CurrentCulture, "String resource {0} not found.", name));
            return res;
        }

        // All these strings should be present in SR.resx
        internal const string Activity = "Activity";
        internal const string Standard = "Standard";
        internal const string Interaction = "Interaction";
        internal const string Navigation = "Navigation";
        internal const string Handlers = "Handlers";
        internal const string ActivityInputTypeDescription = "ActivityInputTypeDescription";
        internal const string ActivityInputDescription = "ActivityInputDescription";
        internal const string ActivityOutputTypeDescription = "ActivityOutputTypeDescription";
        internal const string ActivityOutputDescription = "ActivityOutputDescription";
        internal const string ReceiveInputDescription = "ReceiveInputDescription";
        internal const string RequiredPermissionDescription = "RequiredPermissionDescription";
        internal const string OwnerPermissionDescription = "OwnerPermissionDescription";
        internal const string EnforceOwnerPermissionDescription = "EnforceOwnerPermissionDescription";
        internal const string ErrorDescription = "ErrorDescription";
        internal const string UntilConditionDescription = "UntilConditionDescription";
        internal const string StartWithDescription = "StartWithDescription";
        internal const string TimeoutDurationDescription = "TimeoutDurationDescription";
        internal const string NavigatingHandlerDescription = "NavigatingHandlerDescription";
        internal const string TransitionsDescription = "TransitionsDescription";
        internal const string TargetDescription = "TargetDescription";
        internal const string ConditionDescription = "ConditionDescription";
        internal const string SynchronizationModeDescription = "SynchronizationModeDescription";
        internal const string WorkflowDescriptionDescription = "WorkflowDescriptionDescription";
        internal const string PageUrlDescription = "PageUrlDescription";
        internal const string PageTextDescription = "PageTextDescription";
        internal const string InitializedEventDescription = "InitializedEventDescription";
        internal const string InputArrivedEventDescription = "InputArrivedEventDescription";
        internal const string RestrictAccessDescription = "RestrictAccessDescription";

        internal const string AddNavigator = "AddNavigator";
        internal const string AddingBranch = "AddingBranch";
        internal const string DropActivitiesHere = "DropActivitiesHere";

        internal const string General_MissingService = "General_MissingService";
        internal const string Error_ActivityNotSited = "Error_ActivityNotSited";
        internal const string Error_CantGetDesigner = "Error_CantGetDesigner";
        internal const string Error_CantGetConnectionPoints = "Error_CantGetConnectionPoints";
        internal const string Error_CantFindActivity = "Error_CantFindActivity";
        internal const string Error_UnexpectedArgumentType = "Error_UnexpectedArgumentType";
        internal const string Error_IllegalTransition = "Error_IllegalTransition";
        internal const string Error_InvalidParameterType = "Error_InvalidParameterType";
        internal const string Error_NavigatorActivityNotRoot = "Error_NavigatorActivityNotRoot";
        internal const string Error_InstanceAlreadyCompleted = "Error_InstanceAlreadyCompleted";
        internal const string Error_WorkflowShutdown = "Error_WorkflowShutdown";
        internal const string Error_InvalidTimespanFormat = "Error_InvalidTimespanFormat";
        internal const string Error_UnknownCommand = "Error_UnknownCommand";
        internal const string Error_IncorrectPropertyType = "Error_IncorrectPropertyType";
        internal const string Error_CanNotChangeAtRuntime = "Error_CanNotChangeAtRuntime";
        internal const string Error_TransitionsOnlyApplyToActivity = "Error_TransitionsOnlyApplyToActivity";
        internal const string Error_InvalidPropertyName = "Error_InvalidPropertyName";
        internal const string Error_CantAddService = "Error_CantAddService";
        internal const string Error_CantRemoveService = "Error_CantRemoveService";
        internal const string Error_MissingStartWith = "Error_MissingStartWith";
        internal const string Error_MultipleInteractiveActivity = "Error_MultipleInteractiveActivity";
        internal const string Error_InvalidStartWith = "Error_InvalidStartWith";
        internal const string Error_MissingSynchronizationContextSchedulerService = "Error_MissingSynchronizationContextSchedulerService";
        internal const string Error_AddSchedulerService = "Error_AddSchedulerService";
        internal const string Error_NoIEventActivity = "Error_NoIEventActivity";
        internal const string Error_NoIEventActivityInInteractionActivity = "Error_NoIEventActivityInInteractionActivity";
        internal const string Error_NoStatemachineActivity = "Error_NoStatemachineActivity";
        internal const string Error_NoWebServiceActivity = "Error_NoWebServiceActivity";
        internal const string Error_SyncCommandNotAllowed = "Error_SyncCommandNotAllowed";
        internal const string Error_UnknowQueryCommand = "Error_UnknowQueryCommand";
        internal const string Error_CantDequeueMessage = "Error_CantDequeueMessage";
        internal const string Error_InteractiveActivityCantBeInParallelReplicator = "Error_InteractiveActivityCantBeInParallelReplicator";
        internal const string Error_MissingConfigSection = "Error_MissingConfigSection";
        internal const string Error_MissingWorkflowElement = "Error_MissingWorkflowElement";
        internal const string Error_MissingRulesFileAttribute = "Error_MissingRulesFileAttribute";
        internal const string Error_CantGetHttpContext = "Error_CantGetHttpContext";
        internal const string Error_ChildMustBeInteraction = "Error_ChildMustBeInteraction";
        internal const string Error_ChildCantBeInteraction = "Error_ChildCantBeInteraction";
        internal const string Error_CantFindNavigationState = "Error_CantFindNavigationState";
        internal const string Error_UnknownInputFormat = "Error_UnknownInputFormat";
        internal const string Error_InteractionIdNotFound = "Error_InteractionIdNotFound";
        internal const string Error_HistoryNotFound = "Error_HistoryNotFound";
        internal const string Error_UnexpectedObjectType = "Error_UnexpectedObjectType";
        internal const string Error_CantFindMatchingUrl = "Error_CantFindMatchingUrl";
        internal const string Error_CantFindMatchingException = "Error_CantFindMatchingException";
        internal const string Error_CantGetCurrentContext = "Error_CantGetCurrentContext";
        internal const string Error_WorkflowCanceledByUser = "Error_WorkflowCanceledByUser";
    }

    internal static class ErrorNumbers
    {
        internal const int Error_NavigatorActivityNotRoot = 0x800;
        internal const int Error_MultipleInteractiveActivity = 0x801;
        internal const int Error_InvalidStartWith = 0x802;
        internal const int Error_NoIEventActivity = 0x803;
        internal const int Error_InteractiveActivityCantBeInParallelReplicator = 0x804;
        internal const int Error_ChildMustBeInteraction = 0x805;
        internal const int Error_ChildCantBeInteraction = 0x806;
        internal const int Error_NoStatemachineActivity = 0x807;
        internal const int Error_NoWebServiceActivity = 0x808;
        internal const int Error_NoIEventActivityInInteractionActivity = 0x809;
    }

	internal static class UserDataKeys
	{
        internal static readonly Guid CustomActivity = new Guid("298CF3E0-E9E0-4d41-A11B-506E9132EB27");
        internal static readonly Guid CustomActivityDefaultName = new Guid("8bcd6c40-7bf6-4e60-8eea-bbf40bed92da");
    }

}